# -*- encoding=utf8 -*-
"""
RedFlag-TC000052   （合拍）翻转功能
（合拍）翻转摄像头场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()

log("--------------------------------（合拍）翻转摄像头场景--------------------------------------")
"""
进入合拍
截屏用于断言
点击翻转
截屏用于断言
通过循环点击翻转并进行断言
"""

shooter.enter_the_production_step()
photo1 = shooter.capture_screenshot(file_name="TC000052A.png")
shooter.click_element(in_time_rollover_Button)
photo2 = shooter.capture_screenshot(file_name="TC000052B.png")
for _ in range(10):
    shooter.click_element(in_time_rollover_Button)
    shooter.assert_image_exists(photo1, "断言失败，实际图片与预期图片不符合", threshold = 0.9)
    shooter.click_element(in_time_rollover_Button)
    shooter.assert_image_exists(photo2, "断言失败，实际图片与预期图片不符合", threshold = 0.9)
    
# 关闭应用
stop_app(UGC_package_name)